<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php  date_default_timezone_set("Australia/Melbourne");
$stDetail = new Model_DbTable_Roster_Stafflogindetail();
$leaveList = $this->arrRes2;
?>
<table border="1" cellspacing="0" cellpadding="15" style="padding:15px;">
  <tr>
    <th colspan="2" scope="col">Staff</th>
 <?php foreach($this->arrDate as $dateCheck){?>   
    <th scope="col" colspan="2" style=" width:200px;"><?php echo $dateCheck;?></th>
 <?php }?>   
  </tr>
  <?php foreach($this->arrRes as $people => $date){?>  
  <tr>

    <td><?php echo $people;?>
    </td>
    <td><?php
    $stLine = $stDetail->getDetail($people);
    echo ucwords(Model_EncryptHelper::getSslPassword($stLine['n']));
    echo ucwords(" (".$stLine['ni'].")");
    
    ?></td>
	<?php foreach($date as $k => $v){?>    
    <td style=" width:150px;">
    	<?php 
    		if(!empty($leaveList[$people][$k])){
    			$totalHour2 =  $leaveList[$people][$k]['total_hrs'];
				echo $leaveList[$people][$k]['period_start_hr'].":".str_pad($leaveList[$people][$k]['period_start_min'], 2, "0", STR_PAD_RIGHT)." - ";
				echo $leaveList[$people][$k]['period_end_hr'].":".str_pad($leaveList[$people][$k]['period_end_min'], 2, "0", STR_PAD_RIGHT);
				echo '('.$totalHour2.')';
				echo '<img src="/im/holiday_icon.png"  width="20" />';
				echo "<br/>";
    			
				$totalHour = "?";
				
				if($v[0]!="" && $v[1]!=""){
					$totalHour = round(($v[1]-$v[0])/3600,2);
				}
					
				echo ($v[0]=="")?"-":date ("H:i:s",$v[0]);
				echo "<br/>";
				echo ($v[1]=="")?"-":date ("H:i:s",$v[1]); 
    		}else{
    			$totalHour = "?";
    			$totalHour2 = "?";
    			if($v[0]!="" && $v[1]!=""){
    				$totalHour = round(($v[1]-$v[0])/3600,2);
    			}
    			$startCheck = Model_DatetimeHelper::tranferToInt($k."09:00:00");
    			$endCheck = Model_DatetimeHelper::tranferToInt($k."17:50:00");
				
    			if($v[0] == ""){
    				echo "-";	
    			}else{
    				if($v[0] > $startCheck){
    					echo "<span style=\"background:yellow\">".date ("H:i:s",$v[0])."</span>";
    				}else{
    					echo date ("H:i:s",$v[0]);
    				}
    				
    			}
    				echo "<br/>";
    			if($v[1] == ""){
    				echo "-";
    			}else{
    				if($v[1] < $endCheck){
    					echo "<span style=\"background:yellow\">".date ("H:i:s",$v[1])."</span>";
    				}else{
    					echo date ("H:i:s",$v[1]);
    				}
    				
    			}
    		}
		?>	
    </td>
    <td> <?php
    		if(($totalHour - 0.5 + $totalHour2) >= 12){
    			echo "<span style=\"background:yellow\">".($totalHour - 0.5 + $totalHour2)."</span>";
    		}
    		elseif($totalHour >= 5 && ($totalHour - 0.5 + $totalHour2) >= 8){
    			echo ($totalHour - 0.5 + $totalHour2);}
    		elseif($totalHour >= 5 && ($totalHour - 0.5 + $totalHour2) < 8){
    			echo "<span style=\"background:yellow\">".($totalHour - 0.5 + $totalHour2)."</span>";
    		}else{
    			echo "<span style=\"background:#AAA\">".($totalHour + $totalHour2)."</span>";
    		}
    ?></td>
	<?php }?>
<?php }?>
  </tr>
</table>

	<a href="javascript:history.go(-1)">Back</a>
</body>
</html>